/**
 * Created by yuyongzhen  <1640599564@qq.com>>.
 */

var url = require('../../utils/url.js');
var navis = require('../../config/navis.config.js');

module.exports = function(mod,name){ 
	mod.controller(name,['$scope','$rootScope',function($scope,$rootScope){
		 
		$scope.navis = navis;
		
		$rootScope.$on('$routeChangeSuccess', function(){
			var pathMatchs = url.getPaths(); 
			$scope.paths = [];
			$scope.paths[0] = pathMatchs.length >= 2 ? pathMatchs[1] : '';
			$scope.paths[1] = pathMatchs.length >= 3 ? pathMatchs[2] : '';
		});

		bindEvent();
	}]);
}

function bindEvent(){
	$('#sidebar-container').on('click','.title',function(){
		var $this = $(this);
		if($this.siblings('.subbars-box').hasClass('active')){
			$this.siblings('.subbars-box').removeClass('active');
			return;
		}
		$this.parents('ul').find('.subbars-box').removeClass('active');
		$this.siblings('.subbars-box').addClass('active');
	});
}





